<#include "/ftl/lib/operations.ftl"/>
<div class="easyui-layout" fit="true">  
	<div region="north" style="padding:5px;border:1px solid #ddd; background-color: #f4f4f4" id="global_${action_id}"  >
	</div>  
	<div region="center" border="false">
		<div class="easyui-panel"  data-options="href:'${request.contextPath}${namespace?default('')}/mp/sysres/exception-code-list.htm?action_id=${action_id}',fit:true">
		</div>
	</div>
</div>
<script type="text/javascript">
function add_${action_id}(){
	$('<div/>').dialog({
		href:'${request.contextPath}${namespace?default('')}/mp/sysres/exception-code-form.htm?action_id=${action_id}',
		width:500,   
		height:350,   
		title: '${action.getText('bg.datagrid.add')}',
		modal:true,
		maximizable:false,
		collapsible:false,
		minimizable:false,
		resizable:false,
		buttons:[{iconCls : 'icon-ok',
					text:'${action.getProperty('net.esj.background.message','bg.datagrid.save')}',
					handler:function(){
						var d = $(this).closest('.window-body');
						$('#form_${action_id}').form('submit', {
							url : '${request.contextPath}${namespace?default('')}/mp/sysres/exception-code-add.json',
							onSubmit: function(){
								return $(this).form('validate');
	        				},
							success : function(json) {
								eval("json="+json);
								$.messager.alert(json.title,json.msg,json.level);
								d.dialog('destroy');
								$("#datagrid_${action_id}").datagrid('reload');
							}
						});
					}},
					{iconCls : 'icon-undo',
					text:'${action.getProperty('net.esj.background.message','bg.datagrid.reset')}',
					handler:function(){
						$('#form_${action_id}').form('clear');
					}}],
		onClose : function() {
			$(this).dialog('destroy');
		}
	});
}

function edit_${action_id}(data) {
	$('<div>').dialog({
		href : '${request.contextPath}${namespace?default('')}/mp/sysres/exception-code-edit.htm?action_id=${action_id}&ajax=false&id='+data.id,
		width:500,   
		height:350,   
		modal : true,
		title : '${action.getText('bg.datagrid.edit')}',
		buttons : [ {
			text : '${action.getProperty('net.esj.background.message','bg.datagrid.edit')}',
			iconCls : 'icon-edit',
			handler : function() {
				var d = $(this).closest('.window-body');
				$('#edit_${action_id}').form('submit', {
					url : '${request.contextPath}${namespace?default('')}/mp/sysres/exception-code-update.json',
					onSubmit: function(){
						return $(this).form('validate');
    				},
					success : function(json) {
						eval("json="+json);
						$.messager.alert(json.title,json.msg,json.level);
						d.dialog('destroy');
						$("#datagrid_${action_id}").datagrid('reload');
					}
				});
			}
		} ],
		onClose : function() {
			$(this).dialog('destroy');
		}
	});
}

function delete_${action_id}(data){
	$.messager.confirm('${action.getText('bg.message.info')}', '${action.getText('bg.datagrid.delete.ask')}', function(b) {
		if (b) {
			$.ajax({
				url : '${request.contextPath}${namespace?default('')}/mp/sysres/exception-code-delete.json',
				data:{id : data.id},
				dataType : 'JSON',
				success : function(json) {
					$.messager.alert(json.title,json.msg,json.level);
					$("#datagrid_${action_id}").datagrid('reload');
					$('#datagrid_${action_id}').datagrid('clearSelections');
				}
			});
		}
	});
}

function reload_${action_id}(reload){
	$.ajax({
		url : '${request.contextPath}${namespace?default('')}/mp/sysres/exception-code-reload.json',
		data:{id : data.id},
		dataType : 'JSON',
		success : function(json) {
			$.messager.alert(json.title,json.msg,json.level);
			$("#datagrid_${action_id}").datagrid('reload');
			$('#datagrid_${action_id}').datagrid('clearSelections');
		}
	});
}
</script>
<@operations contextUri='sysres/exception-code' />